from django.contrib.admin.options import ModelAdmin

class CatalogAdmin(ModelAdmin):
    list_display = ('name', 'displayToolTip')
    search_fields = ('name',)
    ordering = ('name',)
    
class ClientAdmin(ModelAdmin):
    list_display = ( 'user','documentNumber', 'address','celularNumber')
    search_fields = ('documentNumber',)
    ordering = ('-documentNumber',)
    list_filter = ('user', 'documentNumber')
    
class PhotoAdmin(ModelAdmin):
    list_display = ('title', 'relativePath', 'description','image')
    search_fields = ('title',)
    ordering = ('-title',)
    
class CategoryAdmin(ModelAdmin):
    list_display = ('name', 'catalog')
    search_fields = ('name',)
    ordering = ('name',)
  
class PriceIncrementAdmin(ModelAdmin):
    list_display = ('rate', 'creationDate')
    search_fields = ('creationDate',)
    ordering = ('-creationDate',)
  
class ProductAdmin(ModelAdmin):
    list_display = ('code', 'category')
    search_fields = ('code',)
    ordering = ('code',)

class OrderProductAdmin(ModelAdmin):
    list_display = ('id', 'product','unitPrice','subTotalPrice','quantity','getCartCode')
    ordering = ('id',)
    def getCartCode(self, obj):
        return '%s'%(obj.cart.code)
    getCartCode.short_description = 'Cart Code'
class CartAdmin(ModelAdmin):
    list_display = ('code','creationDate','state','sessionId','get_user')
    list_filter = ('code', 'creationDate')
    search_fields = ('code',)
    ordering = ('code','state')
    list_display_links = ('code', 'creationDate')
    def get_user(self, obj):
        return '%s'%(obj.user)
    get_user.short_description = 'User'
    
class OrderAdmin(ModelAdmin):
    list_display = ('code','registrationDate','get_state','get_user','cart')
    list_filter = ('code', 'cart')
    search_fields = ('code',)
    ordering = ('code',)
    def get_state(self, obj):
        return '%s'%(obj.cart.state)
    get_state.short_description = 'State' 
    
    def get_user(self, obj):
        return '%s'%(obj.cart.user)
    get_user.short_description = 'User'
    